<?
if(! defined('BASEPATH') ){ exit('Unable to view file.'); }
$del = $db->EscapeString($_GET['del']);

if($del != "" && is_numeric($del)){$db->Query("DELETE FROM `coupons` WHERE `id`='".$del."'");}
?>
            <div id="page-subheader">
                <div class="wrapper clearfix">
                    <nav id="sub-nav">
                        <ul>
                            <li class="active"><a href="index.php?x=coupons">Coupons</a></li>
							<li><a href="index.php?x=addcoupon">Add</a></li>
							</ul>
                    </nav>
                </div>
            </div>
        </header>
        
        <section id="content">
            <div class="wrapper">
                <section class="grid_6 first top">
                    <div class="columns leading">
                        <div class="grid_6 first">
                            <table class="datatable sortable selectable paginate full">
                                <thead>
                                    <tr>
                                        <th width="25">ID</th>
                                        <th>Coupon</th>
										<th>Coins</th>
                                        <th>Used</th>
                                        <th width="15">Actions</th>
                                    </tr>
                                </thead>
								<tfoot>
                                    <tr>
                                        <th width="25">ID</th>
                                        <th>Coupon</th>
										<th>Coins</th>
                                        <th>Used</th>
                                        <th width="15">Actions</th>
                                    </tr>
                                </tfoot>
                                <tbody>
<?
  $sql = $db->Query("SELECT * FROM `coupons`");
  for($j=1; $user = $db->FetchArray($sql); $j++)
{
?>	
                                    <tr>
                                        <td><?=$user['id']?></td>
                                        <td><?=$user['code']?></td>
										<td><?=$user['coins']?></td>
                                        <td><?=($user['used'] == 0 ? 'No' : 'Yes')?></td>
                                        <td><ul class="action-buttons">
										<li><a href="index.php?x=coupons&del=<?=$user['id']?>" class="action-button" title="Delete"><span class="user-delete"></span></a></li></ul></td>
                                    </tr>
<?}?>
                                </tbody>
                            </table>
                        </div>
                    </div>


                    <div class="clear">&nbsp;</div>

                </section>

                <!-- Main Section End -->

                <!-- Sidebar -->

                <aside class="grid_2 top">

                    <div class="accordion">

                        <header class="current"><h2>Info</h2></header>
                        <section style="display:block">
                            Here you can see all coupons used or not!
                        </section>

                    </div>

                </aside>

                <!-- Sidebar End -->
                
                <div class="clear"></div>

            </div>
            <div id="push"></div>
        </section>

    </div>
    
    <footer id="page-footer">
        <div id="footer-inner">
            <p class="wrapper">All rights reserved &copy; <a href="http://mafianet.org" target="_blank">MafiaNet</a> <?=date('Y')?></p>
        </div>
    </footer>
</body>
</html>